<?php
/**
 * 友情链接控制器
 * @author maniac
 */
namespace app\manage\controller;

use app\common\model\LinkCategory;

class Links extends Base
{
    /**
     * 首页补充
     * @param array $data 列表信息
     */
    public function indexAttach($data)
    {
        $this->categories();
    }
    
    /**
     * 添加/编辑补充
     * @param array $info 信息
     */
    public function addAttach($info)
    {
        $this->categories();
    }
    
    /**
     * where 查询条件
     * @return [type] [description]
     */
    public function where()
    {
        $category_id = input('get.category_id/d', 0);
        $where = '';
        if ($category_id) {
            $where = [
                'category_id' => $category_id,
            ];
        }
        return $where;
    }
    
    /**
     * 获取所有友情链接分类
     */
    private function categories()
    {
        $categories = LinkCategory::field('id,name')->order('id ASC')->select();
        $this->assign('categories', $categories);
    }
}
